package com.kws.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kws.common.core.domain.R;
import com.kws.common.log.annotation.Log;
import com.kws.common.log.enums.BusinessType;
import com.kws.system.domain.info.QueryReviewManagementInfo;
import com.kws.system.domain.vo.QueryReviewManagementRq;
import com.kws.system.service.ReviewManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <b>ReviewManagementController</b>
 *
 * @description: ReviewManagementController <br>
 * @date: 2024/11/19 09:00 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "评价管理")
@RestController
public class ReviewManagementController {
    private static final Logger logger = LoggerFactory.getLogger(ReviewManagementController.class);

    @Autowired
    private ReviewManagementService reviewManagementService;

    @ApiOperation("分页查询评价列表")
    @PostMapping("/query/reviewPage")
    public R<Page<QueryReviewManagementInfo>> queryReviewPage(@RequestBody QueryReviewManagementRq rq){
        R<Page<QueryReviewManagementInfo>> pageInfo = reviewManagementService.queryReviewPage(rq);
        return pageInfo;
    }

    @ApiOperation("根据ID查询评价详情")
    @GetMapping("/query/review/byId")
    public R<List<QueryReviewManagementInfo>> queryReviewById(@RequestParam Long id){
        List<QueryReviewManagementInfo> info = reviewManagementService.queryReviewById(id);
        return R.ok(info);
    }

    @ApiOperation("根据ID删除评价")
    @Log(title = "删除评价", businessType = BusinessType.DELETE)
    @GetMapping("/delete/review/byId")
    public R deleteReviewById(@RequestParam Long id){
        boolean status = reviewManagementService.deleteReviewById(id);
        return R.ok(status);
    }
}
